package org.three;

import java.io.*;
import java.net.*;

/**
 * Created by Administrator on 2016/3/14 0014.
 */
public class FileClient {
    public static void main(String[] args) throws IOException {
        String s = File.separator;

        // 设定客户端并尝试连接服务器地址，如果连接成功，则获得服务器Socket
        Socket server = new Socket("192.168.100.64", 7777);

        InputStream is = server.getInputStream();
        OutputStream os = new FileOutputStream("d:" + s + "abc.mp4");

        byte[] b = new byte[1024];
        int number = 0;
        // 从网络中读取到文件流并保留读取到的字节数
        while ( (number = is.read(b)) != -1 ) {
            os.write(b,0,number);       // 将读取到的内容写入到文件
        }

        System.out.println("文件传输完毕...");
        server.close();
    }
}









